#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
struct TreeNode {
    int val;
    struct TreeNode* left;
    struct TreeNode* right;
    
};

    typedef struct TreeNode TreeNode;

int TreeSize(TreeNode* root)
{
    return root == NULL ? 0 : TreeSize(root->left) +
        TreeSize(root->right) + 1;
}
void _preodertraversal(TreeNode* root, int* a, int* pi) {
    if (root == NULL)
        return;
    a[(*pi)++] = root->val;
    _preodertraversal(root->left, a, pi);
    _preodertraversal(root->right, a, pi);
}
int* preorderTraversal(struct TreeNode* root, int* returnSize) {
    *returnSize = TreeSize(root);
    int* arr = (int*)malloc(sizeof(int) * (*returnSize));
    int* i = 0;
    _preodertraversal(root, arr, &i);

    return arr;
}

bool isSameTree(struct TreeNode* p, struct TreeNode* q) {
    if (q == NULL && p == NULL)
        return true;
    if (q == NULL || p == NULL)
        return false;
    if (q->val != p->val)
        return false;

    return isSameTree(p->left, q->left) &&
        isSameTree(p->right, q->right);
}

bool isSameTree(struct TreeNode* p, struct TreeNode* q) {
    if (q == NULL && p == NULL)
        return true;
    if (q == NULL || p == NULL)
        return false;
    if (q->val != p->val)
        return false;

    return isSameTree(p->left, q->right) &&
        isSameTree(p->right, q->left);
}

bool isSymmetric(struct TreeNode* root) {
    return isSameTree(root->left, root->right);
}

bool isSameTree(struct TreeNode* p, struct TreeNode* q) {
    if (q == NULL && p == NULL)
        return true;
    if (q == NULL || p == NULL)
        return false;
    if (q->val != p->val)
        return false;

    return isSameTree(p->left, q->left) &&
        isSameTree(p->right, q->right);
}

bool isSubtree(struct TreeNode* root, struct TreeNode* subRoot) {
    if (root == NULL)
        return false;
    if (root->val == subRoot->val && isSameTree(root, subRoot))
        return true;
    return isSubtree(root->left, subRoot) || isSubtree(root->right, subRoot);
}

typedef struct treeNode
{
    char val;
    struct treeNode* left;
    struct treeNode* right;
}treeNode;


void TreeInOrder(treeNode* root)
{
    if (root == NULL)
        return;
    TreeInOrder(root->left);
    printf("%c ", root->val);
    TreeInOrder(root->right);
}

treeNode* CreateTree(char* s, int* pi)
{
    if (s[(*pi)] == '#')
    {
        (*pi)++;
        return NULL;
    }
    treeNode* root = (treeNode*)malloc(sizeof(treeNode));
    root->val = s[(*pi)++];
    root->left = CreateTree(s, pi);
    root->right = CreateTree(s, pi);
    return root;
}

int main() {
    char s[100];
    scanf("%s", s);
    int i = 0;
    treeNode* root = CreateTree(s, &i);
    TreeInOrder(root);
    return 0;
}